#-*- coding: utf-8 -*-
'''
Created on Jul 21, 2012

@author: bbg
'''
import decimal
import time
import datetime



 


class NiceData:
    '''
    从DB字段装换成protocolbuffer字段，判断DB字段是NULL的情况
    '''
    
    def __init__(self):
        pass
    
    @staticmethod
    def assign(valueLeft, valueRight):
        if type(valueLeft) is bool:
            if valueRight is not None:
                valueLeft = type(valueLeft)(valueRight)
            else:
                valueLeft = False
        elif type(valueLeft) is str or type(valueLeft) is unicode:
            if valueRight is not None:
                valueLeft = type(valueLeft)(valueRight)
            else:
                valueLeft = ""
        elif type(valueLeft) is float or type(valueLeft) is int:
            if valueRight is not None:
                valueLeft = type(valueLeft)(valueRight)
            else:
                valueLeft = 0
        else:
            raise Exception("unsupported assignment")
        
        return valueLeft
        
        
    
        